<template>
	<view class="expert-page">
		<u-navbar title="下单" :autoBack="true" :placeholder="true" bgColor="rgba(255,255,255,0)"></u-navbar>
		<view class="line"></view>
		<view class="content">
			<view class="info-box">
				<view class="distance">
					<u-icon name="map-fill" color="#2D2D2D" size="20"></u-icon>
					<view class="distance-text">
						距离您{{shopinfo.distance}}公里
					</view>
				</view>
				<view class="head-top">
					<view class="head" v-if="info.images">
						<image :src="'https://m.lqvvvv.com'+info.images" mode=""></image>
					</view>
					<view class="head-right">
						<view class="name">
							{{info.name}}
						</view>
						<view class="price">
							￥{{info.price}}
						</view>
					</view>
				</view>
				<view class="feature">
					<view class="feature-item" v-for="(item,index) in shopinfo.tags" :key="index">
						{{item}}
					</view>
				</view>
			</view>
			<view class="info-box">
				<view class="num-box">
					<view class="title">购买份数</view>
					<view><u-number-box v-model="num"></u-number-box></view>
				</view>
			</view>
			<view class="info-box">
				<view class="tel-box">
					<view class="title">手机号码</view>
					<view class="photo">
						<view class="mobile">{{shopinfo.mobile}}</view>
						<u-icon name="phone" @click="gophone(shopinfo.mobile)" color="#999" size="26"></u-icon>
					</view>
				</view>
			</view>
			<view class="info-box">
				<view class="pay-box">
					<view class="title">支付方式</view>
					<view class="paytype" @click="openPay">
						<view class="pay-text">
							{{paytype}}
						</view>
						<u-icon name="arrow-down" color="#999999" size="16"></u-icon>
					</view>
				</view>
			</view>
			<view class="bottom-info">
				<view class="info-left">
					<text>￥{{Number(info.price * num).toFixed(2)}}</text>
				</view>
				<view class="pay-btn" @click="gopay()">
					支付
				</view>
			</view>
		</view>
		<u-picker :show="showPay" :columns="payList" @cancel="showPay = false" @confirm="payHandle"></u-picker>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				checked: true,
				showPay: false,
				info: {},
				shopinfo: {},
				num: 1,
				paytype: '余额',
				payList: [
					// '微信',
					// , '支付宝'
					['余额']
				],
			}
		},
		onLoad(e) {
			this.info = JSON.parse(decodeURIComponent(e.info));
			this.shopinfo = JSON.parse(decodeURIComponent(e.shopinfo));
			console.log(this.info)
			console.log(this.shopinfo)
		},
		methods: {
			gopay(){
				let params = {
					product_id: this.info.id,
					num:this.num
				}
				uni.showLoading({
					mask:true
				})
				this.$Request({
					method: 'POST',
					url: '/api/shop_order/add',
					data: params,
					ismsg: true,
				}).then(res => {
					uni.hideLoading()
					if (res.code == 1) {
						setTimeout(()=>{
							uni.navigateBack({
								delta:1
							})
						},1000)
					}
				})
			},
			payHandle(e) {
				this.paytype = e.value[0]
				this.showPay = false
			},
			openPay() {
				this.showPay = true
			},
			goend() {
				uni.showLoading({
					mask: true
				})
				let params = {
					orderid: this.id,
					// #ifdef APP
					method: 'app',
					// #endif
					// #ifdef H5
					method: 'web',
					// #endif
					// #ifdef MP-WEIXIN
					method: 'miniapp',
					// #endif
					paytype: this.info.paytype
				}
				this.$Request({
					method: 'POST',
					url: '/api/friend_order/payResidue',
					data: params,
					ismsg: true,
				}).then(res => {
					console.log(res)
					uni.hideLoading()
					if (res.code == 1) {
						this.postdetails()
					}
				})
			},
			gophone(tel) {
				uni.makePhoneCall({
					phoneNumber: tel //仅为示例
				});
			},
		}
	}
</script>

<style>
	page {
		background-color: #F7F8FC;
	}
</style>
<style lang="scss" scoped>
	.expert-page {
		min-height: 100vh;
		background-image: url('https://m.lqvvvv.com/assets/static/index/nav-bg.png');
		background-repeat: no-repeat;
		background-size: 100% 800rpx;


		.content {
			padding: 30rpx;

			.bottom-info {
				position: fixed;
				bottom: 0;
				left: 0;
				right: 0;
				display: flex;
				align-items: center;
				justify-content: space-between;
				background-color: #FFFFFF;
				padding: 30rpx;

				.info-left {
					text {
						font-size: 50rpx;
						color: #FB345F;
					}
				}

				.pay-btn {
					width: 140rpx;
					background-image: url('https://m.lqvvvv.com/assets/static/index/make-bg.png');
					background-repeat: no-repeat;
					background-size: 100% 100%;
					padding: 30rpx;
					color: #fff;
					text-align: center;
				}
			}

			.info-box {
				background-color: #fff;
				border-radius: 20rpx;
				padding: 20rpx 30rpx;
				margin-bottom: 20rpx;



				.num-box {
					display: flex;
					align-items: center;
					justify-content: space-between;

					.title {
						font-weight: 500;
						font-size: 28rpx;
						color: #000000;
					}
				}

				.pay-box {
					display: flex;
					align-items: center;
					justify-content: space-between;

					.title {
						font-weight: 500;
						font-size: 28rpx;
						color: #000000;
					}

					.paytype {
						display: flex;
						align-items: center;

						.pay-text {
							margin-right: 10rpx;
						}
					}
				}

				.tel-box {
					display: flex;
					align-items: center;
					justify-content: space-between;

					.title {
						font-weight: 500;
						font-size: 28rpx;
						color: #000000;
					}

					.photo {
						display: flex;
						align-items: center;

						.mobile {
							margin-right: 10rpx;
						}
					}
				}

				.distance {
					display: flex;
					align-items: center;
					color: #9799AC;
					font-size: 24rpx;

					.distance-text {
						margin-left: 10rpx;
					}
				}

				.head-top {
					display: flex;
					margin-top: 31rpx;
					border-bottom: 1rpx solid #f0f0f0;
					padding-bottom: 29rpx;

					.head {
						margin-right: 40rpx;

						image {
							width: 129rpx;
							height: 129rpx;
							border-radius: 10rpx;
						}
					}

					.head-right {
						width: 100%;

						.name {
							font-weight: 500;
							font-size: 30rpx;
							color: #2D2D2D;
						}

						.price {
							text-align: right;
							font-weight: 600;
							font-size: 28rpx;
							color: #FB345F;
						}
					}
				}

				.feature {
					display: flex;
					margin-top: 20rpx;

					.feature-item {
						border: 1rpx solid #5755F2;
						padding: 5rpx 10rpx;
						border-radius: 10rpx;
						font-size: 20rpx;
						margin-right: 20rpx;
						color: #5755F2;
					}
				}
			}

		}
	}
</style>